var attendanceType;
var id;
var groupid;
var iconid;
var subid;
var menuid;
var index;
var taskDetailsListTijaio;
var taskDetailsList;

var eventStar;
var eventStar2;

var  task_id;
var  userId;
$(function () {
    groupid = ly.getUrlParam("groupid");
    iconid = ly.getUrlParam("iconid");
    subid = ly.getUrlParam("subid");
    menuid = ly.getUrlParam("menuid");


    attendanceType = ly.getUrlParam("attendanceType");
    id = ly.getUrlParam("id");


	$("#reasonsRevocation").getSelect({
        type: "radio",
        asName: "reasonsRevocation",
        code: "reasonsRevocation",
       // default: data.taskCategories
    });

        $(".form").getForm({
            'ajaxform': true,
            exceptionTaskId: id
        }, function (data) {
                console.log(data)
                task_id = data.taskId;
                userId = data.userId;
                if(data.handlerStatus == 0){
					$("input[name='map']").eq(0).attr("checked",true)
				}else if(data.handlerStatus == 1){
					$("input[name='map']").eq(1).attr("checked",true)
				}else if(data.handlerStatus == 2){
                    $("input[name='map']").eq(2).attr("checked",true)
                }
                eventStar = data.handlerStatus;
                // if(data.reasonsRevocation =1){
                //     $("#input[name='reasonsRevocation']")
                // }
            
                $("input[name='reasonsRevocation']").eq(data.reasonsRevocation-1).attr("checked",true)
        });
 


	$("input[name=map]").on("click",function(){

		eventStar = this.value
	});

    $("#reasonsRevocation").on("input", "input[name='reasonsRevocation']", function () {
          
            eventStar2 =$(this).val()
    });

    //提交
    $("body").on("click", "#save-btn-commodityClassification", function (event) {
        event.preventDefault();
        var success = $('.form').validate('submitValidate');
        if (success) {
            //验证通过提交表单
            submitFom();
        }
    })




});



/*
 * 提交表单
 */
function submitFom() {


    var taskName = $("#taskName").val();
    var taskStatement = $("#taskStatement").val();

  
    var taskExceptionDescription  = {
       'exeptionContext': taskStatement,
        'exceptionStatus': eventStar,
        'exceptionId':id,
        'taskId':task_id,
        'userId':userId
    };
 
    var url = site.apiUrl + "/back/task/updateExceptionTask"; //apiUrl


    request({
        url: url,
        data: taskExceptionDescription,
        type: "get",
        ajaxform: true,
        callback: function (f) {
            console.log(f);
            if (f.code == "rest.success") {

                ly.alert('修改成功', function () {
                    ly.goto("task-fail.html");
                });

            } else {
                ly.toast(f.desc);
            }
        }
    });

}